import requests from "./requests";
let getNavBar = async () => await requests.get('/navbar');
let goLogin = (username, password) => requests.post('/alogin', { username: username, password: password });
let goRegister = (obj) => requests.post('/register', obj);

let getArticles = async () => await requests.post('/article');

let putBase64Img = async (imgName, base64) => await requests.post('/uploadImgToYun', { imgName: imgName, base64: base64 });

let insertArticle = async (formData) => await requests.post('/insertArticle', formData);

let queryArticleById = async (id) => await requests.post('/queryArticleById', { id });

let queryByArticleId = async (id) => await requests.get('/queryByArticle', {
    params: { id }
});
let getgetcomments = async (aid) => await requests.get('/getcommentByAid', { params: { aid } });
// 提交评论
let commit_comment = async (aid, userName, comment, commentAvatar) => await requests.post('/setcomment', {
    aid, userName, comment, commentAvatar
});
let commitLikeNumber = async (aid, Likenum) => await requests.post('/addLikeNum', {
    aid, Likenum
});
let getUserInfo = async (id) => await requests.get('/queryUserInfoById', { params: { id } });
let UpdateUserInfo = async (data) => await requests.post('/updateUserInfo', data);

// 查询记账列表
let queryAcountList = async ({ uid, startTime, endTime, pageNum, pageSize }) => await requests.post('/queryAccount', { uid, startTime, endTime, pageNum, pageSize });
// 添加记账
let addAccountReq = async (data) => await requests.post('/addAccount', data);
// 获取统计接口
let getStatisticsApi = async ({ uid, startTime, endTime }) => await requests.post('/totalAccount', { uid, startTime, endTime });
// 删除记账记录接口
let deleteAccountReq = async (date) => await requests.get('/deleteAccount', { params: date });
// 添加卡接口
let addCardReq = async (data) => await requests.post('/addCard', data);
// 上传图片接口
let uploadImg = async (formData) => await requests.post('/uploadMobileImg', formData, {
    headers: {
        'Content-Type': 'multipart/form-data'
    }
});
// 查询卡列表
let queryCardList = async (uid) => await requests.post('/queryCard', { uid });
// 导出接口
let exportExcel = async () => await requests.get('http://localhost:3456/excel', { responseType: 'blob' });
export {
    getNavBar, goLogin, getArticles, putBase64Img, insertArticle, queryArticleById,
    queryByArticleId, getgetcomments, commit_comment, commitLikeNumber,
    goRegister, getUserInfo, UpdateUserInfo, queryAcountList, addAccountReq, getStatisticsApi,
    deleteAccountReq, addCardReq, uploadImg, queryCardList, exportExcel
}